package com.xixibaby.redis;


import com.zengtengpeng.operation.RedissonCollection;
import com.zengtengpeng.operation.RedissonObject;
import org.redisson.api.RedissonClient;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;


public class Redis implements ApplicationContextAware {

    private static RedissonObject redissonObject;

    private static RedissonCollection redissonCollection;

    private static RedissonClient redissonClient;

    @Override
    public  void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        redissonCollection = applicationContext.getBean(RedissonCollection.class);
        redissonObject = applicationContext.getBean(RedissonObject.class);
        redissonClient = applicationContext.getBean(RedissonClient.class);
    }

    public static void set(String key,String value){
        redissonObject.setValue(key,value);
    }

    public static String get(String key){
        return redissonObject.getValue(key);
    }

}

